#ifndef TEXTEDITOR_H
#define TEXTEDITOR_H
#include "tabmanager.h"
#include <QMainWindow>
#include <QTextEdit>
#include <QMenu>
#include <QMenuBar>
#include <QLineEdit>
#include <QToolBar>
#include <QToolButton>
#include <QHBoxLayout>
#include <QWidget>
#include <QFileDialog>
#include <QMessageBox>

class TabManager;

class TextEditor  : public QMainWindow
{
    Q_OBJECT

public:
    TextEditor(TabManager* );
    QAction *find_cancel = nullptr;
    QAction *replace_cancel = nullptr;
    QAction *find_replace = nullptr;
    QAction *find_start = nullptr;
    QAction *find_next = nullptr;
    QAction *find_replace_all = nullptr;
    QAction *find_replace_select = nullptr;
    QLineEdit *find_input = nullptr;
    QLineEdit *replace_input = nullptr;
    QToolButton *cancel_button = nullptr;
    QToolButton *replace_button = nullptr;
    QToolButton *start_button = nullptr;
    QToolButton *next_button = nullptr;
    QToolButton *replace_all_button = nullptr;
    QToolButton *replace_select_button = nullptr;
    QToolButton *replace_cancel_button = nullptr;
    QWidget *spacer = nullptr;
    QWidget *spacer_ = nullptr;
public slots:
    void on_copy();
    void on_paste();
    void on_cut();
    void on_selectAll();
    void on_find_and_replace();

    void on_find_cancel();
    void on_replace_all();
    void on_replace_select();
    void on_replace_cancel();
    void on_find_text(const QString &);
    void on_find_start();
    void on_find_next();
    void on_replace();
    void on_text_changed_find();

private:
    TabManager* tabManager = nullptr;
    bool start_flag = false;
    QTextCursor start_cursor;
    QTextDocument *document = nullptr;
};


#endif // TEXTEDITOR_H
